<#import "/macro.ftl" as m>
<@m.page_header title='后台' />
<script type="text/javascript" src="/assets/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/assets/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="/assets/ueditor/lang/zh-cn/zh-cn.js"></script>
<div id="page-content-wrapper">

    <div id="page-title">

        <h3>
            添加红包
        </h3>

    </div>
    <div class="pad10A">

        <form id="demo-form1" action="/redpacket/release" class="col-md-12" method="POST" enctype="multipart/form-data">

            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        导入接收人号码:
                    </label>
                </div>
                <div class="col-md-6">
                    <input type="file" name="file" value="导入">
                </div>
            </div>

            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        接收人号码:
                    </label>
                </div>
                <div class="form-input col-md-6">
                    使用英文输入法的逗号 “,” 作为分隔
                    <textarea id="mobiles" name="mobiles" data-trigger="change"
                              class="parsley-validated"></textarea>
                </div>
            </div>

            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        金额:
                        <span class="required">*</span>
                    </label>
                </div>
                <div class="form-input col-md-6">
                    <input type="text" name="amount" data-type="number" data-trigger="change" data-required="true" class="parsley-validated" value="">
                </div>
            </div>

            <#--<div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        过期时间:
                        <span class="required">*</span>
                    </label>
                </div>
                <div class="form-input col-md-8">
                    <input type="text" id="expiredDate" name="expiredDate" data-trigger="focus" data-required="true" class="parsley-validated"
                           onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                           style="clear:both;overflow:hidden;display:block">
                </div>
            </div>-->

            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        具体描述:
                        <span class="required">*</span>
                    </label>
                </div>
                <div class="form-input col-md-8">
                    <textarea id="description" name="description" data-trigger="change" class="parsley-validated"></textarea>
                </div>
            </div>

            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        编码:
                        <span class="required">*</span>
                    </label>
                </div>
                <div class="form-input col-md-6">
                    <select id="code" name="code">

                    </select>
                </div>
            </div>

            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="">
                        期限:
                        <span class="required">*</span>
                    </label>
                </div>
                <div class="form-input col-md-6">
                    <input type="text" id="term" name="term" data-type="number" data-trigger="change" data-required="true" class="parsley-validated">
                </div>
            </div>

            <div class="divider"></div>
            <div class="form-row">
                <input type="hidden" name="superhidden" id="superhidden">
                <div class="form-input col-md-10 col-md-offset-2">
                    <a href="javascript:;" class="btn medium primary-bg radius-all-4 col-md-2" id="demo-form-2-valid">

                        提交

                    </a>
                </div>
            </div>

        </form>
    </div>
</div>

<script type="text/javascript">
    $(function(){
        $("#demo-form-2-valid").click(function(){
            $('#demo-form1').parsley('validate');
            $('#demo-form1').trigger('submit');
        });
    });

    //请求所有的红包策略
    $("#code").click(function(){
        $.get("/redpacket/allredpacket", function(data){
            var html = "";
            var  list = data.list;
            for(var i = 0; i < list.length; i++){
                html += "<option value ='"+list[i].code+"'>"+list[i].name+"</option>";
            }
            $("#code").append(html);
        });
        $("#code").unbind();
    });

    $("mobiles").blur(function(){

        $.get("/redpacket/allredpacket", function(data){
            var html = "";
            var  list = data.list;
            for(var i = 0; i < list.length; i++){
                html += "<option value ='"+list[i].code+"'>"+list[i].name+"</option>";
            }
            $("#code").append(html);
        });

        $("input").css("background-color","#D6D6FF");
    });

</script>